package car;

public class Car {

	private int numberOfSeats;
	private String model;
	private int maxSpeed;
	private int currentSpeed;
	private String color;
	private int currentGear;
	private Person owner;
	private String idNumber;
	private boolean isSportCar=false;
	private boolean driverHaveUnpaiedTaxes;
	
	
	Car() {
		setModel("");
		setCurrentGear(0);
		setCurrentSpeed(0);
		setIdNumber("0000000");
		setMaxSpeed(0);
		setSportCar(false);
	}
	
	
	
	public int getNumberOfSeats() {
		return numberOfSeats;
	}

	public void setNumberOfSeats(int numberOfSeats) {
		if (numberOfSeats >= 0 && numberOfSeats < 50)
			this.numberOfSeats = numberOfSeats;
	}

	public String getIdNumber() {
		return idNumber;
	}

	public void setIdNumber(String idNumber) {
		if (idNumber != null && idNumber.length() >= 0)
			this.idNumber = idNumber;
	}

	public boolean isSportCar() {
		return isSportCar;
	}

	public void setSportCar(boolean isSportCar) {
		this.isSportCar = isSportCar;
	}

	public String getModel() {
		return model;
	}

	public void setModel(String model) {
		if (model != null)
			this.model = model;
	}

	public int getMaxSpeed() {
		return maxSpeed;
	}

	public void setMaxSpeed(int maxSpeed) {
		if (maxSpeed > 0)
			this.maxSpeed = maxSpeed;
	}

	public int getCurrentSpeed() {
		return currentSpeed;
	}

	public void setCurrentSpeed(int currentSpeed) {
		if (currentSpeed > 0)
			this.currentSpeed = currentSpeed;
	}

	public String getColor() {
		return color;
	}

	public void setColor(String color) {
		if (color != null && color.length() >= 0)
			this.color = color;
	}

	public int getCurrentGear() {
		return currentGear;
	}

	public void setCurrentGear(int i) {
		if (i >= 0 && i <= 6)
			this.currentGear = i;
	}

	public Person getOwner() {
		return owner;
	}

	public void setOwner(Person owner) {
		if (owner != null)
			this.owner = owner;
	}

	void accelerate(double speed) {
		if (speed >= 0) {
			if (currentSpeed <= maxSpeed - speed)
				currentSpeed += speed;
		}
	}

	void changeGearUp() {
		if (currentGear < 5) {
			currentGear++;
		}
	}

	void changeGearDown() {
		if (currentGear > 1) {
			currentGear--;
		}
	}

	void changeGear(int nextGear) {
		if (currentGear + nextGear <= 5 && currentGear + nextGear >= 1) {
			currentGear += nextGear;
		}
	}

	void changeColor(String newColor) {
		if (newColor != null) {
			color = newColor;
		}
	}

	public boolean isDriverHaveUnpaiedTaxes() {
		return driverHaveUnpaiedTaxes;
	}

	public void setDriverHaveUnpaiedTaxes(boolean driverHaveUnpaiedTaxes) {
		this.driverHaveUnpaiedTaxes = driverHaveUnpaiedTaxes;
	}
	
	void startEngine(){
		setCurrentGear(1);
	}
	
	@Override
	public String toString() {
		return model + " " + " max speed: " + maxSpeed + (isSportCar? " sport car " : " not sport car" )  +"\n";
	}
	

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Car){
			Car otherCar = (Car) obj;
			return this.model.equals(otherCar.getModel()) && this.color.equals(otherCar.color);
		}
		return super.equals(obj);
	}
}
